module.exports = app => {
    const {STRING,INTEGER,DATE} = app.Sequelize;
    var User = require('../model/user')
    const CloudAnimal = app.model.define('cloud_animal', {
        id: {
            type: INTEGER(20),
            primaryKey: true,
            autoIncrement: true
        },
        animalName: {
            type: STRING(20),
            allowNull: false,
            defaultValue: '',
            comment: '动物名字'
        },
        species: {
            type: INTEGER(11),
            allowNull: false,
            defaultValue: 0,
            comment: '0狗1猫'
        },
        stationId: {
            type: INTEGER(20),
            allowNull: false,
            defaultValue: 0,
            comment: '隶属救助站ID'
        },
        stationName: {
            type: STRING(30),
            allowNull: false,
            defaultValue: '',
            comment: '救助站名称'
        },
        sterilized: {
            type: INTEGER(11),
            allowNull: false,
            defaultValue: 0,
            comment: '0未绝育1已绝育'
        },
        immune: {
            type: INTEGER(11),
            allowNull: false,
            defaultValue: 0,
            comment: '0未免疫1已免疫'
        },
        parasite: {
            type: INTEGER(11),
            allowNull: false,
            defaultValue: 0,
            comment: '0未驱虫1已驱虫'
        },
        animalBrief: {
            type: STRING(20),
            allowNull: false,
            defaultValue: '',
            comment: '动物简介'
        },
        animalIntroduction: {
            type: STRING(1000),
            allowNull: false,
            defaultValue: '',
            comment: '动物介绍'
        },
        claimPrice: {
            type: INTEGER(11),
            allowNull: false,
            defaultValue: 0,
            comment: '云领养价格'
        },
        claimStatus: {
            type: INTEGER(11),
            allowNull: false,
            defaultValue: 0,
            comment: '0未被领养1已被领养'
        },
        ownerId: {
            type: INTEGER(20),
            allowNull: false,
            defaultValue: 1,
            comment: '云领养者ID'
        },
        startTime: {
            type: DATE,
            comment: '云领养开始时间'
        },
        endTime: {
            type: DATE,
            comment: '云领养结束时间'
        },
        created_time:DATE,
        updated_time:DATE
    });
    CloudAnimal.associate = function(){
        CloudAnimal.belongsTo(app.model.User,{as:'owner_info',foreignKey:'owner_id',targetKey:'id'});
        CloudAnimal.belongsTo(app.model.RescueStation,{as:'station_info',foreignKey:'station_id',targetKey:'id'});
    }
    return CloudAnimal;
}